Skip to content

feat(entrykit): non-blocking fee estimation - #3784

Merged
alvrs merged 7 commits into
mainfrom
alvrs/entrykit-fee-estimation
Jul 10, 2025
Merged

feat(entrykit): non-blocking fee estimation#3784
alvrs merged 7 commits into
mainfrom
alvrs/entrykit-fee-estimation

Conversation

@alvrs

@alvrs alvrs commented Jul 10, 2025

Copy link
Copy Markdown
Member

No description provided.

@changeset-bot

changeset-bot Bot commented Jul 10, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a0f2d3c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@latticexyz/entrykit Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/explorer Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/paymaster Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
vite-plugin-mud Patch
@latticexyz/world-consumer Patch
@latticexyz/world-module-callwithsignature Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

if ([690, 17069, 695569].includes(client.chain.id)) {
// TODO: move to fee ref or similar approach
return () => getAction(client, estimateFeesPerGas, "estimateFeesPerGas")({ chain: client.chain });
return cachedFeesPerGas(client);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

viem prioritizes this method over the chain's estimateFeesPerGas config: https://github.com/wevm/viem/blob/3aa882692d2c4af3f5e9cc152099e07cde28e551/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L447. If we override only the estimateFeesPerGas config, we still have one unnecessary call for getBlock: https://github.com/wevm/viem/blob/3aa882692d2c4af3f5e9cc152099e07cde28e551/src/actions/public/estimateFeesPerGas.ts#L132

@frolic frolic Jul 10, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently viem no longer does this "3 gwei minimum" thing like it used to

previous: https://github.com/wevm/viem/blob/253b1072ad9fe36a0e0491e173c85a6d69209ada/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L436-L457

now: https://github.com/wevm/viem/blob/main/src/account-abstraction/actions/bundler/prepareUserOperation.ts#L469-L483

which landed here and is now in mud: wevm/viem@9a7e864

so maybe we update the comment to say "we override this here to avoid an unnecessary getBlock call"?

Comment thread packages/entrykit/src/utils/withFeeCache.ts
@alvrs
alvrs marked this pull request as ready for review July 10, 2025 12:11
refreshInterval?: number;
};

export function withFeeCache(chain: Chain, options: WithFeeCacheOptions = { refreshInterval: 10_000 }): Chain {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export function withFeeCache(chain: Chain, options: WithFeeCacheOptions = { refreshInterval: 10_000 }): Chain {
export function withFeeCache<const chain extends Chain>(chain: chain, options: WithFeeCacheOptions = { refreshInterval: 10_000 }): chain {

just to keep strong types

@vercel
vercel Bot temporarily deployed to Preview – explorer July 10, 2025 12:41 Inactive
@alvrs
alvrs merged commit 7cd553a into main Jul 10, 2025
17 checks passed
@alvrs
alvrs deleted the alvrs/entrykit-fee-estimation branch July 10, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants